<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopPayConfigTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_pay_config', ['comment' => '支付配置', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('name', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '名称'])
            ->addColumn(Column::enum('type', ['wechat', 'alipay'])->setNull(true)->setDefault(null)->setComment('类型:wechat=微信,alipay=支付宝'))
            ->addColumn('params', 'string', ['limit' => 2500, 'null' => true, 'default' => null, 'comment' => '参数'])
            ->addColumn(Column::enum('status', ['normal', 'disabled'])->setDefault('normal')->setComment('状态:normal=正常,disabled=禁用'))
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '删除时间'])
            ->addIndex('type')
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_pay_config');
        $table->drop();
    }
}
